package com.wander.designCreational.builder.newbuilder;

import java.math.BigDecimal;

/**
 * @Author WDYin
 * @Date 2021/7/20
 * @Description
 **/
public class Product {
    //主键
    private Long id;
    //产品名称
    private String name;
    //产品类型
    private String type;
    //产品价格
    private Double price;

    public Product() {
    }

    public Product(Builder builder) {
        this.id = builder.id;
        this.name = builder.name;
        this.type = builder.type;
        this.price = builder.price;
    }

    public static class Builder {
        //主键
        private Long id;
        //产品名称
        private String name;
        //产品类型
        private String type;
        //产品价格
        private Double price;

        public Builder() {

        }

        public Builder setId(Long id) {
            this.id = id;
            return this;
        }

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setType(String type) {
            this.type = type;
            return this;
        }

        public Builder setPrice(Double price) {
            this.price = price;
            return this;
        }

        public Product build() {
            return new Product(this);
        }
    }
}

